<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<c:set var="webroot" value="${pageContext.request.contextPath}" />
<html>
<head>
	<meta charset="utf-8">
	<title>新增备注</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="${webroot}/static/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="${webroot}/static/css/public.css" media="all" />
<style type="text/css">
 .layui-input-block {
    margin-left: 32px;
 }
 .layui-input, .layui-textarea {
    width: 120%;
    height: 72%;
}
 .layui-form-item {
    text-align: center;
 }
</style>
</head>
<body class="childrenBody">
<form class="layui-form" style="width:80%;">
    <input type="hidden" id="id">
    <input type="hidden" id="mark">
	<div class="layui-form-item layui-row layui-col-xs12">
		<div class="layui-input-block">
			<textarea placeholder="请输入备注" class="layui-textarea remark" lay-verify="required"></textarea>
		</div>
	</div>
	<div class="layui-form-item layui-row layui-col-xs12">
		<div class="layui-input-block">
			<button class="layui-btn" lay-submit="" lay-filter="addBorrow">保存</button>
		</div>
	</div>
</form>
<script src="${webroot}/static/js/jquery.min.js" charset="utf-8"></script>
<script type="text/javascript" src="${webroot}/static/layui/layui.js"></script>
<script>
layui.use(['form','layer','laydate'],function(){
    var form = layui.form
        layer = parent.layer === undefined ? layui.layer : top.layer,
        $ = layui.jquery,
        laydate = layui.laydate,
        laytpl = layui.laytpl,
        table = layui.table;
    laydate.render({
        elem: '#startTime'
    });
    laydate.render({
        elem: '#endTime'
    });
    form.on("submit(addBorrow)",function(data){
        //弹出loading
    	var record="";
    	if($("#mark").val() != ""){
    		record="编辑借款:";
    	}else{
    		record="添加借款:";
    	}
        var index = top.layer.msg('数据提交中，请稍候',{icon: 16,time:false,shade:0.8});
        // 实际使用时的提交信息
        $.post("/admin/borrow/update",{
        	 id : $("#id").val(),
        	 remark : $(".remark").val(),  
             record : record
         },function(res){
        	 var data=JSON.parse(res);
        	 if(data.success){
        		top.layer.close(index);
  	            top.layer.msg("操作成功");
  	            setTimeout(function(){
  	            	var index = parent.layer.getFrameIndex(window.name);
  	            	parent.layer.close(index);
  	            },3000);  
        	 }else{
        		 top.layer.msg(data.message);
        	 }
        })
        return false;
    })
    
      $(".layui-btn-normal").on("click",function(){
    	  var index = layui.layer.open({
              title : "选择借款人",
              type : 2,
	          area : ["700px","450px"],
	          content : "/admin/borrow/selectlist",
          })
      })

    //格式化时间
    function filterTime(val){
        if(val < 10){
            return "0" + val;
        }else{
            return val;
        }
    }
    //定时发布
    var time = new Date();
    var submitTime = time.getFullYear()+'-'+filterTime(time.getMonth()+1)+'-'+filterTime(time.getDate())+' '+filterTime(time.getHours())+':'+filterTime(time.getMinutes())+':'+filterTime(time.getSeconds());
})
function close_self(){
	window.location.href="/admin/userinfo/showlist";
}
</script>
</body>
</html>